﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：WTB_WENJIANXX实体层次
//********************************************************************************//
#region Entity
namespace Entity
{
    using System;
    using System.Xml;
    [Serializable()]
    public class WTB_WENJIANXX
    {

        private int m_bt_id;
        /// <summary>
        /// ID自增长，禁止关联
        /// </summary>
        public int ID { get { return m_bt_id; } set { m_bt_id = value; } }

        private string m_str_s_zhubiaobh;
        /// <summary>
        /// 主表编号
        /// </summary>
        public string S_ZHUBIAOBH { get { return m_str_s_zhubiaobh; } set { m_str_s_zhubiaobh = value; } }

        private string m_str_incident_id;
        /// <summary>
        /// 申请单唯一ID
        /// </summary>
        public string INCIDENT_ID { get { return m_str_incident_id; } set { m_str_incident_id = value; } }

        private string m_str_cert_source;
        /// <summary>
        /// 证件来源 01：证照库；02：用户上传；
        /// </summary>
        public string CERT_SOURCE { get { return m_str_cert_source; } set { m_str_cert_source = value; } }

        private string m_str_cert_type;
        /// <summary>
        /// 证件类型
        /// </summary>
        public string CERT_TYPE { get { return m_str_cert_type; } set { m_str_cert_type = value; } }

        private string m_str_cert_number;
        /// <summary>
        /// 证件号码
        /// </summary>
        public string CERT_NUMBER { get { return m_str_cert_number; } set { m_str_cert_number = value; } }

        private string m_str_file_uuid;
        /// <summary>
        /// 证照UUID
        /// </summary>
        public string FILE_UUID { get { return m_str_file_uuid; } set { m_str_file_uuid = value; } }

        private string m_str_filename;
        /// <summary>
        /// 文件名
        /// </summary>
        public string FILENAME { get { return m_str_filename; } set { m_str_filename = value; } }

        private string m_str_web_uri;
        /// <summary>
        /// Web URI
        /// </summary>
        public string WEB_URI { get { return m_str_web_uri; } set { m_str_web_uri = value; } }

        private int? m_bt_i_beiyong1;
        /// <summary>
        /// 
        /// </summary>
        public int? I_BEIYONG1 { get { return m_bt_i_beiyong1; } set { m_bt_i_beiyong1 = value; } }

        private int? m_bt_i_beiyong2;
        /// <summary>
        /// 
        /// </summary>
        public int? I_BEIYONG2 { get { return m_bt_i_beiyong2; } set { m_bt_i_beiyong2 = value; } }

        private int? m_bt_i_beiyong3;
        /// <summary>
        /// 
        /// </summary>
        public int? I_BEIYONG3 { get { return m_bt_i_beiyong3; } set { m_bt_i_beiyong3 = value; } }

        private string m_str_s_beiyong1;
        /// <summary>
        /// 人员类型|材料类型
        /// </summary>
        public string S_BEIYONG1 { get { return m_str_s_beiyong1; } set { m_str_s_beiyong1 = value; } }

        private string m_str_s_beiyong2;
        /// <summary>
        /// 人员名称
        /// </summary>
        public string S_BEIYONG2 { get { return m_str_s_beiyong2; } set { m_str_s_beiyong2 = value; } }

        private string m_str_s_beiyong3;
        /// <summary>
        /// 证件地址
        /// </summary>
        public string S_BEIYONG3 { get { return m_str_s_beiyong3; } set { m_str_s_beiyong3 = value; } }

        private DateTime? m_DT_d_beiyong1;
        /// <summary>
        /// 证件生效日期
        /// </summary>
        public DateTime? D_BEIYONG1 { get { return m_DT_d_beiyong1; } set { m_DT_d_beiyong1 = value; } }

        private DateTime? m_DT_d_beiyong2;
        /// <summary>
        /// 证件失效日期
        /// </summary>
        public DateTime? D_BEIYONG2 { get { return m_DT_d_beiyong2; } set { m_DT_d_beiyong2 = value; } }

        private DateTime? m_DT_d_beiyong3;
        /// <summary>
        /// 
        /// </summary>
        public DateTime? D_BEIYONG3 { get { return m_DT_d_beiyong3; } set { m_DT_d_beiyong3 = value; } }
        public WTB_WENJIANXX()
        {
        }
    }
}
#endregion
#region EntityProcess
namespace Access.BLL
{
    using System;
    using System.Data;
    //using System.Data.OracleClient;
    using Entity;
    using System.Configuration;
    using System.Data.Common;
    using Platform.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    using Oracle.DataAccess;
    public class WTB_WENJIANXXProcess
    {
        #region Field
        protected string conn;
        #endregion
        #region Construction
        public WTB_WENJIANXXProcess() { conn = Platform.Configuration.ConfigHelper.BusinessConnString; }
        #endregion
        #region public

        /// <summary>
        /// 根据WTB_WENJIANXX实体添加或者修改WTB_WENJIANXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_WENJIANXX WTB_WENJIANXX, OracleTransaction Transaction)
        {
            if (WTB_WENJIANXX.ID == 0)
            {
                InsertWTB_WENJIANXX(WTB_WENJIANXX, Transaction);
            }
            else
            {
                UpdateWTB_WENJIANXX(WTB_WENJIANXX, Transaction);
            }
            return WTB_WENJIANXX.ID == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_WENJIANXX实体添加或修改WTB_WENJIANXX信息
        /// </summary>
        public bool InsertOrUpdate(WTB_WENJIANXX WTB_WENJIANXX)
        {
            return InsertOrUpdate(WTB_WENJIANXX, null);
        }



        /// <summary>
        /// 根据WTB_WENJIANXX主键删除WTB_WENJIANXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_WENJIANXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_WENJIANXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据WTB_WENJIANXX主键删除WTB_WENJIANXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteWTB_WENJIANXX(int ID)
        {
            return DeleteWTB_WENJIANXX(ID, null);
        }

        /// <summary>
        /// 根据条件删除WTB_WENJIANXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_WENJIANXXesDynamic(string WhereClause, OracleTransaction Transaction)
        {
            string spName = "CS_DelWTB_WENJIANXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        /// 根据条件删除WTB_WENJIANXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteWTB_WENJIANXXesDynamic(string WhereClause)
        {
            return DeleteWTB_WENJIANXXesDynamic(WhereClause, null);
        }

        /// <summary>
        /// 根据WTB_WENJIANXX主键选择WTB_WENJIANXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_WENJIANXX信息</returns>
        public WTB_WENJIANXX SelectWTB_WENJIANXX(int ID, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_WENJIANXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                WTB_WENJIANXX WTB_WENJIANXX = PopulateWTB_WENJIANXX(rd);
                rd.Close();
                return WTB_WENJIANXX;
            }
            else
                return null;
        }

        /// <summary>
        /// 根据WTB_WENJIANXX主键选择WTB_WENJIANXX信息
        /// </summary>
        /// <returns>WTB_WENJIANXX信息</returns>
        public WTB_WENJIANXX SelectWTB_WENJIANXX(int ID)
        {
            return SelectWTB_WENJIANXX(ID, null);
        }

        /// <summary>
        /// 选择所有WTB_WENJIANXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有WTB_WENJIANXX信息</returns>
        public DataTable SelectWTB_WENJIANXXesAll(OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_WENJIANXXesAll";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }

        /// <summary>
        /// 选择所有WTB_WENJIANXX信息
        /// </summary>
        /// <returns>所有WTB_WENJIANXX信息</returns>
        public DataTable SelectWTB_WENJIANXXesAll()
        {
            return SelectWTB_WENJIANXXesAll(null);
        }

        /// <summary>
        /// 根据条件选择WTB_WENJIANXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_WENJIANXX信息</returns>
        public DataTable SelectWTB_WENJIANXXesDynamic(string WhereClause, string OrderByExpression, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_WENJIANXXesDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_WENJIANXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>WTB_WENJIANXX信息</returns>
        public DataTable SelectWTB_WENJIANXXesDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectWTB_WENJIANXXesDynamic(WhereClause, OrderByExpression, null);
        }



        /// <summary>
        /// 根据条件选择WTB_WENJIANXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>WTB_WENJIANXX信息</returns>
        public DataTable SelectWTB_WENJIANXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize, OracleTransaction Transaction)
        {
            string spName = "CS_SelWTB_WENJIANXXesDynPaged";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            else
                return null;
        }


        /// <summary>
        /// 根据条件选择WTB_WENJIANXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>WTB_WENJIANXX信息</returns>
        public DataTable SelectWTB_WENJIANXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex, int PageSize)
        {
            return SelectWTB_WENJIANXXesDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///根据条件更新WTB_WENJIANXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_WENJIANXXesDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            int result = 0;
            if (UpdateValue == "" || WhereClause == "")
            {
                return 0;
            }
            string spName = "CS_UpdWTB_WENJIANXXDyn";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///根据条件更新WTB_WENJIANXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateWTB_WENJIANXXesDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateWTB_WENJIANXXesDynamic(UpdateValue, WhereClause, null);
        }


        #endregion
        #region Private

        private int InsertWTB_WENJIANXX(WTB_WENJIANXX WTB_WENJIANXX, OracleTransaction Transaction)
        {
            string spName = "CS_InsWTB_WENJIANXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_WENJIANXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_WENJIANXX.INCIDENT_ID;
            storedParams[2].Value = WTB_WENJIANXX.CERT_SOURCE;
            storedParams[3].Value = WTB_WENJIANXX.CERT_TYPE;
            storedParams[4].Value = WTB_WENJIANXX.CERT_NUMBER;
            storedParams[5].Value = WTB_WENJIANXX.FILE_UUID;
            storedParams[6].Value = WTB_WENJIANXX.FILENAME;
            storedParams[7].Value = WTB_WENJIANXX.WEB_URI;
            storedParams[8].Value = WTB_WENJIANXX.I_BEIYONG1;
            storedParams[9].Value = WTB_WENJIANXX.I_BEIYONG2;
            storedParams[10].Value = WTB_WENJIANXX.I_BEIYONG3;
            storedParams[11].Value = WTB_WENJIANXX.S_BEIYONG1;
            storedParams[12].Value = WTB_WENJIANXX.S_BEIYONG2;
            storedParams[13].Value = WTB_WENJIANXX.S_BEIYONG3;
            storedParams[14].Value = WTB_WENJIANXX.D_BEIYONG1;
            storedParams[15].Value = WTB_WENJIANXX.D_BEIYONG2;
            storedParams[16].Value = WTB_WENJIANXX.D_BEIYONG3;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            WTB_WENJIANXX.ID = Convert.ToInt32(storedParams[17].Value);
            return result;
        }
        private bool UpdateWTB_WENJIANXX(WTB_WENJIANXX WTB_WENJIANXX, OracleTransaction Transaction)
        {
            string spName = "CS_UpdWTB_WENJIANXX";
            OracleParameter[] storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WTB_WENJIANXX.S_ZHUBIAOBH;
            storedParams[1].Value = WTB_WENJIANXX.INCIDENT_ID;
            storedParams[2].Value = WTB_WENJIANXX.CERT_SOURCE;
            storedParams[3].Value = WTB_WENJIANXX.CERT_TYPE;
            storedParams[4].Value = WTB_WENJIANXX.CERT_NUMBER;
            storedParams[5].Value = WTB_WENJIANXX.FILE_UUID;
            storedParams[6].Value = WTB_WENJIANXX.FILENAME;
            storedParams[7].Value = WTB_WENJIANXX.WEB_URI;
            storedParams[8].Value = WTB_WENJIANXX.I_BEIYONG1;
            storedParams[9].Value = WTB_WENJIANXX.I_BEIYONG2;
            storedParams[10].Value = WTB_WENJIANXX.I_BEIYONG3;
            storedParams[11].Value = WTB_WENJIANXX.S_BEIYONG1;
            storedParams[12].Value = WTB_WENJIANXX.S_BEIYONG2;
            storedParams[13].Value = WTB_WENJIANXX.S_BEIYONG3;
            storedParams[14].Value = WTB_WENJIANXX.D_BEIYONG1;
            storedParams[15].Value = WTB_WENJIANXX.D_BEIYONG2;
            storedParams[16].Value = WTB_WENJIANXX.D_BEIYONG3;
            storedParams[17].Value = WTB_WENJIANXX.ID;
            int result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery((OracleTransaction)Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private WTB_WENJIANXX PopulateWTB_WENJIANXX(IDataReader dr)
        {
            WTB_WENJIANXX WTB_WENJIANXX = new WTB_WENJIANXX();
            WTB_WENJIANXX.ID = dr["ID"] == DBNull.Value ? (int)0 : (int)dr["ID"];
            WTB_WENJIANXX.S_ZHUBIAOBH = dr["S_ZHUBIAOBH"] == DBNull.Value ? null : (string)dr["S_ZHUBIAOBH"];
            WTB_WENJIANXX.INCIDENT_ID = dr["INCIDENT_ID"] == DBNull.Value ? null : (string)dr["INCIDENT_ID"];
            WTB_WENJIANXX.CERT_SOURCE = dr["CERT_SOURCE"] == DBNull.Value ? null : (string)dr["CERT_SOURCE"];
            WTB_WENJIANXX.CERT_TYPE = dr["CERT_TYPE"] == DBNull.Value ? null : (string)dr["CERT_TYPE"];
            WTB_WENJIANXX.CERT_NUMBER = dr["CERT_NUMBER"] == DBNull.Value ? null : (string)dr["CERT_NUMBER"];
            WTB_WENJIANXX.FILE_UUID = dr["FILE_UUID"] == DBNull.Value ? null : (string)dr["FILE_UUID"];
            WTB_WENJIANXX.FILENAME = dr["FILENAME"] == DBNull.Value ? null : (string)dr["FILENAME"];
            WTB_WENJIANXX.WEB_URI = dr["WEB_URI"] == DBNull.Value ? null : (string)dr["WEB_URI"];
            WTB_WENJIANXX.I_BEIYONG1 = dr["I_BEIYONG1"] == DBNull.Value ? null : (int?)dr["I_BEIYONG1"];
            WTB_WENJIANXX.I_BEIYONG2 = dr["I_BEIYONG2"] == DBNull.Value ? null : (int?)dr["I_BEIYONG2"];
            WTB_WENJIANXX.I_BEIYONG3 = dr["I_BEIYONG3"] == DBNull.Value ? null : (int?)dr["I_BEIYONG3"];
            WTB_WENJIANXX.S_BEIYONG1 = dr["S_BEIYONG1"] == DBNull.Value ? null : (string)dr["S_BEIYONG1"];
            WTB_WENJIANXX.S_BEIYONG2 = dr["S_BEIYONG2"] == DBNull.Value ? null : (string)dr["S_BEIYONG2"];
            WTB_WENJIANXX.S_BEIYONG3 = dr["S_BEIYONG3"] == DBNull.Value ? null : (string)dr["S_BEIYONG3"];
            WTB_WENJIANXX.D_BEIYONG1 = dr["D_BEIYONG1"] == DBNull.Value ? null : (DateTime?)dr["D_BEIYONG1"];
            WTB_WENJIANXX.D_BEIYONG2 = dr["D_BEIYONG2"] == DBNull.Value ? null : (DateTime?)dr["D_BEIYONG2"];
            WTB_WENJIANXX.D_BEIYONG3 = dr["D_BEIYONG3"] == DBNull.Value ? null : (DateTime?)dr["D_BEIYONG3"];
            return WTB_WENJIANXX;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
            }
        }
        #endregion
    }
}
#endregion